import java.io.*;
import java.awt.*;
import java.net.*;

public class JAPI
{

    public static void main(String[] args) throws InterruptedException, MalformedURLException
    {
        ServerSocket listensock=null;
        Socket  clientsock=null;
        Socket  actionsock=null;

        try
        {
            if(args.length==0)
	            listensock=new ServerSocket(JAPI_Calls.JAPI_PORT);
    		else
    			listensock=new ServerSocket((new Integer(args[0])).intValue());
        }catch(IOException e)
        {
			System.out.println("Error : Could not listen at the specified port");
			new JAPI_Alert(new Frame(),"JAPI ERROR","Error : Could not listen at the specified port\nJAPI Port="+JAPI_Calls.JAPI_PORT+"\n"+
			                           "Maybe, there is another application using this port\n"+
			                           "or you have a personal firewall running","Ok");
			System.exit(1);
		}

        while(true)
        {
            try
            {
                clientsock = listensock.accept();
                actionsock = listensock.accept();
            }catch(IOException e) {}

            /* neuen Thread starten */
            new JAPI_Thread(clientsock,actionsock);
        }
    }
}

